using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Terminal.Advanced_AEUC_settings_controls.Settings_Interfaces;
using Terminal.Advanced_AEUC_settings_controls.Settings_AUX;
using Terminal.Advanced_AEUC_settings_controls.Settings_Editing_Forms;
using Terminal.Advanced_AEUC_settings_controls.Setting_Advanced_Control;

namespace Terminal.Advanced_AEUC_settings_controls.Settings_AUX
{
    /// <summary>
    /// A container class for system specifics of messages
    /// </summary>
    public class CommonMSGControl : IAEUCSerialization
    {
        const int Version = 0x007;

        AEUCTabbedParentControl parentTabControl;

        /// <summary>
        /// Constructor taking parent control reference
        /// </summary>
        /// <param name="iparentTabControl">reference to the AEUC tabbed control holder</param>
        public CommonMSGControl(AEUCTabbedParentControl iparentTabControl)
        {
            parentTabControl = iparentTabControl;
        }

        #region Messaging
        /// <summary>
        /// List containing possible message destinations
        /// </summary>
        public List<GenMSGDestination> MSG_DEST = new List<GenMSGDestination>();
        /// <summary>
        /// The default AEUC destination
        /// </summary>
        public GenMSGDestination MSG_DEST_AEUC;
        /// <summary>
        /// The default SPECMSG destination
        /// </summary>
        public GenMSGDestination MSG_DEST_SPECMSG;
        /// <summary>
        /// The starting "stuffing" character used for stream synchronyzation (obsolete, used for backward compatibility)
        /// </summary>
        public Byte MSG_START_CHAR = 0xF0;

        /// <summary>
        /// List containing all the AEUC related messages
        /// </summary>
        public List<GenMSG> AEUC_MSG = new List<GenMSG>();
        /// <summary>
        /// List containing all the AEUC related message ids
        /// </summary>
        public List<GenMSGId> AEUC_MSG_ID = new List<GenMSGId>();
        /// <summary>
        /// List containing all the AEUC related message states
        /// </summary>
        public List<GenMSGStatus> AEUC_MSG_STAT = new List<GenMSGStatus>();

        /// <summary>
        /// List containing all the SPECMSG related messages
        /// </summary>
        public List<GenMSG> SPECMSG_MSG = new List<GenMSG>();
        /// <summary>
        /// List containing all the SPECMSG related message ids
        /// </summary>
        public List<GenMSGId> SPECMSG_MSG_ID = new List<GenMSGId>();
        /// <summary>
        /// List containing all the SPECMSG related message states
        /// </summary>
        public List<GenMSGStatus> SPECMSG_MSG_STAT = new List<GenMSGStatus>();

        /// <summary>
        /// he message that is mapped to the Set OMX component parameter functionality.
        /// </summary>
        public GenMSG msgOMXSetCompParam = null;
        /// <summary>
        /// The message that is mapped to the Set OMX component config functionality.
        /// </summary>
        public GenMSG msgOMXSetCompConf = null;
        /// <summary>
        /// he message that is mapped to the Get OMX component parameter functionality.
        /// </summary>
        public GenMSG msgOMXGetCompParam = null;
        /// <summary>
        /// The message that is mapped to the Get OMX component config functionality.
        /// </summary>
        public GenMSG msgOMXGetCompConf = null;
        /// <summary>
        /// The message that is mapped to the Get OMX component instance functionality.
        /// </summary>
        public GenMSG msgOMXGetCompInstance = null;
        /// <summary>
        /// The message that is mapped to the Get OMX component ports functionality.
        /// </summary>
        public GenMSG msgOMXGetCompPorts = null;
        /// <summary>
        /// The message that is mapped to the allocate OMX component port buffers functionality.
        /// </summary>
        public GenMSG msgOMXAllocPortBuffs = null;
        /// <summary>
        /// The message that is mapped to the linking of different OMX component ports functionality.
        /// </summary>
        public GenMSG msgOMXLinkCompPorts = null;
        /// <summary>
        /// The message that is mapped to OMX component commands functionality.
        /// </summary>
        public GenMSG msgOMXCompCmds = null;
        /// <summary>
        /// The message that is mapped to system generic data transfer message.
        /// </summary>
        public GenMSG msgSYSDataMsg = null;
        /// <summary>
        /// The message that is mapped to system marshalling memory allocation message.
        /// </summary>
        public GenMSG msgSYSMarshalAlloc = null;
        /// <summary>
        /// The message that is mapped to system marshalling memory free message.
        /// </summary>
        public GenMSG msgSYSMarshalFree = null;
        /// <summary>
        /// The message that is mapped to system marshalling memory copy message.
        /// </summary>
        public GenMSG msgSYSMarshalCopy = null;
        /// <summary>
        /// The message that is mapped to system marshalling memory dump message.
        /// </summary>
        public GenMSG msgSYSMarshalDump = null;
        /// <summary>
        /// The message that is mapped to system marshalling memory allocation type message.
        /// </summary>
        public GenMSG msgSYSMarshalAllocType = null;

        /// <summary>
        /// Currently bound control status for data transfer - initialization
        /// </summary>
        public GenMSGStatus msgCtrlStatDataInit = null;
        /// <summary>
        /// Currently bound control status for data transfer - first packet
        /// </summary>
        public GenMSGStatus msgCtrlStatDataStart = null;
        /// <summary>
        /// Currently bound control status for data transfer - partial packet
        /// </summary>
        public GenMSGStatus msgCtrlStatDataMore = null;
        /// <summary>
        /// Currently bound control status for data transfer - final packet
        /// </summary>
        public GenMSGStatus msgCtrlStatDataEnd = null;
        /// <summary>
        /// Currently bound control status for data transfer - full packet
        /// </summary>
        public GenMSGStatus msgCtrlStatDataFull = null;
        /// <summary>
        /// Currently bound control status for data transfer type jpeg - THIS IS NOT A MESSAGE STATUS
        /// </summary>
        public GenMSGStatus msgCtrlStatDataTypeJpeg = null;
        /// <summary>
        /// Currently bound control status for data transfer type information - THIS IS NOT A MESSAGE STATUS
        /// </summary>
        public GenMSGStatus msgCtrlStatDataTypeInfo = null;

        #endregion

        /// <summary>
        /// The common settings delimiter id value
        /// </summary>
        public UInt16 SettingDelimitor = 0;
        /// <summary>
        /// A refference to the currently(last) selected tab page
        /// </summary>
        public TabPage CurrentTabPage;

        #region IAEUCSerialization Members
        /// <summary>
        /// Current element serialization state version
        /// </summary>
        public int serVersion
        {
            get
            {
                return Version;
            }
        }
        /// <summary>
        /// Saves this objec instance to a file
        /// </summary>
        /// <param name="srWriter">Binray writer of the associated file</param>
        public void Serialize(System.IO.BinaryWriter srWriter)
        {
            srWriter.Write(serVersion);
            Serialize_v007(srWriter);
        }
        /// <summary>
        /// Loads this objects instance from a file
        /// </summary>
        /// <param name="srReader">Binray reader of the associated file</param>
        /// <returns>Boolean representing the success of the operation</returns>
        public bool Deserialize(System.IO.BinaryReader srReader)
        {
            bool desProcState;
            int serialVer = srReader.ReadInt32();

            switch (serialVer)
            {
                case 0x000:
                    desProcState = Deserialize_v000(srReader);
                    break;
                case 0x001:
                    desProcState = Deserialize_v001(srReader);
                    break;
                case 0x002:
                    desProcState = Deserialize_v002(srReader);
                    break;
                case 0x003:
                    desProcState = Deserialize_v003(srReader);
                    break;
                case 0x004:
                    desProcState = Deserialize_v004(srReader);
                    break;
                case 0x005:
                    desProcState = Deserialize_v005(srReader);
                    break;
                case 0x006:
                    desProcState = Deserialize_v006(srReader);
                    break;
                case 0x007:
                    desProcState = Deserialize_v007(srReader);
                    break;
                default:
                    desProcState = false;
                    break;
            }

            return desProcState;
        }

        #region Version 0x000 serialization
        /// <summary>
        /// Version 0x000 serialization
        /// </summary>
        /// <param name="srWriter">File writer</param>
        void Serialize_v000(System.IO.BinaryWriter srWriter)
        {
            #region Wtire destination
            srWriter.Write(MSG_DEST.Count);
            for (int i = 0; i < MSG_DEST.Count; i++)
            {
                MSG_DEST[i].Serialize(srWriter);
            }
            #endregion

            #region Write predifined AEUC/SPECMSG message destinations
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_AEUC == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_SPECMSG == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            #endregion

            srWriter.Write(MSG_START_CHAR);

            #region Write AEUC message id
            srWriter.Write(AEUC_MSG_ID.Count);
            for (int i = 0; i < AEUC_MSG_ID.Count; i++)
            {
                AEUC_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write AEUC message status
            srWriter.Write(AEUC_MSG_STAT.Count);
            for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
            {
                AEUC_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message id
            srWriter.Write(SPECMSG_MSG_ID.Count);
            for (int i = 0; i < SPECMSG_MSG_ID.Count; i++)
            {
                SPECMSG_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message status
            srWriter.Write(SPECMSG_MSG_STAT.Count);
            for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
            {
                SPECMSG_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write the AEUC messages
            srWriter.Write(AEUC_MSG.Count);
            for (int i = 0; i < AEUC_MSG.Count; i++)
            {
                ((IAEUCSerialization)AEUC_MSG[i]).Serialize(srWriter);
            }
            #endregion

            #region Write the SPECMSG messages
            srWriter.Write(SPECMSG_MSG.Count);
            for (int i = 0; i < SPECMSG_MSG.Count; i++)
            {
                ((IAEUCSerialization)SPECMSG_MSG[i]).Serialize(srWriter);
            }
            #endregion

            srWriter.Write(SettingDelimitor);
        }
        /// <summary>
        /// Version 0x000 deserialization
        /// </summary>
        /// <param name="srReader">File reader</param>
        /// <returns>True if operation is succesful</returns>
        bool Deserialize_v000(System.IO.BinaryReader srReader)
        {
            bool NoError = true;
            try
            {
                int specLoad;

                #region Load destinations
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGDestination tmpDest = new GenMSGDestination();
                    NoError = tmpDest.Deserialize(srReader);
                    MSG_DEST.Add(tmpDest);
                }
                #endregion

                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_AEUC = MSG_DEST[specLoad];
                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_SPECMSG = MSG_DEST[specLoad];
                MSG_START_CHAR = srReader.ReadByte();

                #region Load AEUC message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    AEUC_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load AEUC message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    AEUC_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load SPECMSG message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    SPECMSG_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load SPECMSG message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    SPECMSG_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load the AEUC messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    AEUC_MSG.Add(tmpMsg);
                }
                #endregion

                #region Load the SPECMSG messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    SPECMSG_MSG.Add(tmpMsg);
                }
                #endregion

                SettingDelimitor = srReader.ReadUInt16();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return NoError;
        }
        #endregion

        #region Version 0x001 serialization
        /// <summary>
        /// Version 0x000 serialization
        /// </summary>
        /// <param name="srWriter">File writer</param>
        void Serialize_v001(System.IO.BinaryWriter srWriter)
        {
            #region Wtire destination
            srWriter.Write(MSG_DEST.Count);
            for (int i = 0; i < MSG_DEST.Count; i++)
            {
                MSG_DEST[i].Serialize(srWriter);
            }
            #endregion

            #region Write predifined AEUC/SPECMSG message destinations
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_AEUC == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_SPECMSG == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            #endregion

            srWriter.Write(MSG_START_CHAR);

            #region Write AEUC message id
            srWriter.Write(AEUC_MSG_ID.Count);
            for (int i = 0; i < AEUC_MSG_ID.Count; i++)
            {
                AEUC_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write AEUC message status
            srWriter.Write(AEUC_MSG_STAT.Count);
            for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
            {
                AEUC_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message id
            srWriter.Write(SPECMSG_MSG_ID.Count);
            for (int i = 0; i < SPECMSG_MSG_ID.Count; i++)
            {
                SPECMSG_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message status
            srWriter.Write(SPECMSG_MSG_STAT.Count);
            for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
            {
                SPECMSG_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write the AEUC messages
            srWriter.Write(AEUC_MSG.Count);
            for (int i = 0; i < AEUC_MSG.Count; i++)
            {
                ((IAEUCSerialization)AEUC_MSG[i]).Serialize(srWriter);
            }
            #endregion

            #region Write the SPECMSG messages
            srWriter.Write(SPECMSG_MSG.Count);
            for (int i = 0; i < SPECMSG_MSG.Count; i++)
            {
                ((IAEUCSerialization)SPECMSG_MSG[i]).Serialize(srWriter);
            }
            #endregion

            srWriter.Write(SettingDelimitor);

            #region Write msgOMXGetCompInstance specific message instance
            if (msgOMXGetCompInstance == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
        }
        /// <summary>
        /// Version 0x000 deserialization
        /// </summary>
        /// <param name="srReader">File reader</param>
        /// <returns>True if operation is succesful</returns>
        bool Deserialize_v001(System.IO.BinaryReader srReader)
        {
            bool NoError = true;
            try
            {
                int specLoad;

                #region Load destinations
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGDestination tmpDest = new GenMSGDestination();
                    NoError = tmpDest.Deserialize(srReader);
                    MSG_DEST.Add(tmpDest);
                }
                #endregion

                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_AEUC = MSG_DEST[specLoad];
                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_SPECMSG = MSG_DEST[specLoad];
                MSG_START_CHAR = srReader.ReadByte();

                #region Load AEUC message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    AEUC_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load AEUC message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    AEUC_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load SPECMSG message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    SPECMSG_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load SPECMSG message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    SPECMSG_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load the AEUC messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    AEUC_MSG.Add(tmpMsg);
                }
                #endregion

                #region Load the SPECMSG messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    SPECMSG_MSG.Add(tmpMsg);
                }
                #endregion

                SettingDelimitor = srReader.ReadUInt16();

                #region Load msgOMXGetCompInstance specific message instance
                int specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompInstance = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return NoError;
        }
        #endregion

        #region Version 0x002 serialization
        /// <summary>
        /// Version 0x000 serialization
        /// </summary>
        /// <param name="srWriter">File writer</param>
        void Serialize_v002(System.IO.BinaryWriter srWriter)
        {
            #region Wtire destination
            srWriter.Write(MSG_DEST.Count);
            for (int i = 0; i < MSG_DEST.Count; i++)
            {
                MSG_DEST[i].Serialize(srWriter);
            }
            #endregion

            #region Write predifined AEUC/SPECMSG message destinations
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_AEUC == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_SPECMSG == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            #endregion

            srWriter.Write(MSG_START_CHAR);

            #region Write AEUC message id
            srWriter.Write(AEUC_MSG_ID.Count);
            for (int i = 0; i < AEUC_MSG_ID.Count; i++)
            {
                AEUC_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write AEUC message status
            srWriter.Write(AEUC_MSG_STAT.Count);
            for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
            {
                AEUC_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message id
            srWriter.Write(SPECMSG_MSG_ID.Count);
            for (int i = 0; i < SPECMSG_MSG_ID.Count; i++)
            {
                SPECMSG_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message status
            srWriter.Write(SPECMSG_MSG_STAT.Count);
            for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
            {
                SPECMSG_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write the AEUC messages
            srWriter.Write(AEUC_MSG.Count);
            for (int i = 0; i < AEUC_MSG.Count; i++)
            {
                ((IAEUCSerialization)AEUC_MSG[i]).Serialize(srWriter);
            }
            #endregion

            #region Write the SPECMSG messages
            srWriter.Write(SPECMSG_MSG.Count);
            for (int i = 0; i < SPECMSG_MSG.Count; i++)
            {
                ((IAEUCSerialization)SPECMSG_MSG[i]).Serialize(srWriter);
            }
            #endregion

            srWriter.Write(SettingDelimitor);

            #region Write msgOMXGetCompInstance specific message instance
            if (msgOMXGetCompInstance == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompPorts specific message instance
            if (msgOMXGetCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXAllocPortBuffs specific message instance
            if (msgOMXAllocPortBuffs == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXLinkCompPorts specific message instance
            if (msgOMXLinkCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
        }
        /// <summary>
        /// Version 0x000 deserialization
        /// </summary>
        /// <param name="srReader">File reader</param>
        /// <returns>True if operation is succesful</returns>
        bool Deserialize_v002(System.IO.BinaryReader srReader)
        {
            bool NoError = true;
            try
            {
                int specLoad;

                #region Load destinations
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGDestination tmpDest = new GenMSGDestination();
                    NoError = tmpDest.Deserialize(srReader);
                    MSG_DEST.Add(tmpDest);
                }
                #endregion

                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_AEUC = MSG_DEST[specLoad];
                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_SPECMSG = MSG_DEST[specLoad];
                MSG_START_CHAR = srReader.ReadByte();

                #region Load AEUC message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    AEUC_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load AEUC message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    AEUC_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load SPECMSG message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    SPECMSG_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load SPECMSG message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    SPECMSG_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load the AEUC messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    AEUC_MSG.Add(tmpMsg);
                }
                #endregion

                #region Load the SPECMSG messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    SPECMSG_MSG.Add(tmpMsg);
                }
                #endregion

                SettingDelimitor = srReader.ReadUInt16();

                #region Load msgOMXGetCompInstance specific message instance
                int specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompInstance = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXAllocPortBuffs specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXAllocPortBuffs = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXLinkCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXLinkCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return NoError;
        }
        #endregion

        #region Version 0x003 serialization
        /// <summary>
        /// Version 0x000 serialization
        /// </summary>
        /// <param name="srWriter">File writer</param>
        void Serialize_v003(System.IO.BinaryWriter srWriter)
        {
            #region Wtire destination
            srWriter.Write(MSG_DEST.Count);
            for (int i = 0; i < MSG_DEST.Count; i++)
            {
                MSG_DEST[i].Serialize(srWriter);
            }
            #endregion

            #region Write predifined AEUC/SPECMSG message destinations
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_AEUC == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_SPECMSG == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            #endregion

            srWriter.Write(MSG_START_CHAR);

            #region Write AEUC message id
            srWriter.Write(AEUC_MSG_ID.Count);
            for (int i = 0; i < AEUC_MSG_ID.Count; i++)
            {
                AEUC_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write AEUC message status
            srWriter.Write(AEUC_MSG_STAT.Count);
            for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
            {
                AEUC_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message id
            srWriter.Write(SPECMSG_MSG_ID.Count);
            for (int i = 0; i < SPECMSG_MSG_ID.Count; i++)
            {
                SPECMSG_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message status
            srWriter.Write(SPECMSG_MSG_STAT.Count);
            for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
            {
                SPECMSG_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write the AEUC messages
            srWriter.Write(AEUC_MSG.Count);
            for (int i = 0; i < AEUC_MSG.Count; i++)
            {
                ((IAEUCSerialization)AEUC_MSG[i]).Serialize(srWriter);
            }
            #endregion

            #region Write the SPECMSG messages
            srWriter.Write(SPECMSG_MSG.Count);
            for (int i = 0; i < SPECMSG_MSG.Count; i++)
            {
                ((IAEUCSerialization)SPECMSG_MSG[i]).Serialize(srWriter);
            }
            #endregion

            srWriter.Write(SettingDelimitor);

            #region Write msgOMXGetCompInstance specific message instance
            if (msgOMXGetCompInstance == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompPorts specific message instance
            if (msgOMXGetCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXAllocPortBuffs specific message instance
            if (msgOMXAllocPortBuffs == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXLinkCompPorts specific message instance
            if (msgOMXLinkCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXCompCmds specific message instance
            if (msgOMXCompCmds == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXCompCmds)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXCompCmds)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
        }
        /// <summary>
        /// Version 0x000 deserialization
        /// </summary>
        /// <param name="srReader">File reader</param>
        /// <returns>True if operation is succesful</returns>
        bool Deserialize_v003(System.IO.BinaryReader srReader)
        {
            bool NoError = true;
            try
            {
                int specLoad;

                #region Load destinations
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGDestination tmpDest = new GenMSGDestination();
                    NoError = tmpDest.Deserialize(srReader);
                    MSG_DEST.Add(tmpDest);
                }
                #endregion

                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_AEUC = MSG_DEST[specLoad];
                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_SPECMSG = MSG_DEST[specLoad];
                MSG_START_CHAR = srReader.ReadByte();

                #region Load AEUC message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    AEUC_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load AEUC message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    AEUC_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load SPECMSG message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    SPECMSG_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load SPECMSG message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    SPECMSG_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load the AEUC messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    AEUC_MSG.Add(tmpMsg);
                }
                #endregion

                #region Load the SPECMSG messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    SPECMSG_MSG.Add(tmpMsg);
                }
                #endregion

                SettingDelimitor = srReader.ReadUInt16();

                #region Load msgOMXGetCompInstance specific message instance
                int specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompInstance = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXAllocPortBuffs specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXAllocPortBuffs = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXLinkCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXLinkCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXCompCmds specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXCompCmds = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXCompCmds = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXCompCmds = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return NoError;
        }
        #endregion

        #region Version 0x004 serialization
        /// <summary>
        /// Version 0x004 serialization
        /// </summary>
        /// <param name="srWriter">File writer</param>
        void Serialize_v004(System.IO.BinaryWriter srWriter)
        {
            #region Wtire destination
            srWriter.Write(MSG_DEST.Count);
            for (int i = 0; i < MSG_DEST.Count; i++)
            {
                MSG_DEST[i].Serialize(srWriter);
            }
            #endregion

            #region Write predifined AEUC/SPECMSG message destinations
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_AEUC == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_SPECMSG == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            #endregion

            srWriter.Write(MSG_START_CHAR);

            #region Write AEUC message id
            srWriter.Write(AEUC_MSG_ID.Count);
            for (int i = 0; i < AEUC_MSG_ID.Count; i++)
            {
                AEUC_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write AEUC message status
            srWriter.Write(AEUC_MSG_STAT.Count);
            for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
            {
                AEUC_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message id
            srWriter.Write(SPECMSG_MSG_ID.Count);
            for (int i = 0; i < SPECMSG_MSG_ID.Count; i++)
            {
                SPECMSG_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message status
            srWriter.Write(SPECMSG_MSG_STAT.Count);
            for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
            {
                SPECMSG_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write the AEUC messages
            srWriter.Write(AEUC_MSG.Count);
            for (int i = 0; i < AEUC_MSG.Count; i++)
            {
                ((IAEUCSerialization)AEUC_MSG[i]).Serialize(srWriter);
            }
            #endregion

            #region Write the SPECMSG messages
            srWriter.Write(SPECMSG_MSG.Count);
            for (int i = 0; i < SPECMSG_MSG.Count; i++)
            {
                ((IAEUCSerialization)SPECMSG_MSG[i]).Serialize(srWriter);
            }
            #endregion

            srWriter.Write(SettingDelimitor);

            #region Write msgOMXGetCompInstance specific message instance
            if (msgOMXGetCompInstance == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompPorts specific message instance
            if (msgOMXGetCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXAllocPortBuffs specific message instance
            if (msgOMXAllocPortBuffs == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXLinkCompPorts specific message instance
            if (msgOMXLinkCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXCompCmds specific message instance
            if (msgOMXCompCmds == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXCompCmds)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXCompCmds)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompConf specific message instance
            if (msgOMXGetCompConf == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompConf)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompConf)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXSetCompConf specific message instance
            if (msgOMXSetCompConf == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXSetCompConf)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXSetCompConf)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompParam specific message instance
            if (msgOMXGetCompParam == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompParam)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompParam)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXSetCompParam specific message instance
            if (msgOMXSetCompParam == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXSetCompParam)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXSetCompParam)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSDataMsg specific message instance
            if (msgSYSDataMsg == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSDataMsg)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSDataMsg)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion

            #region Write msgCtrlStatDataEnd specific message instance
            if (msgCtrlStatDataEnd == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataEnd)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataEnd)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataFull specific message instance
            if (msgCtrlStatDataFull == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataFull)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataFull)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataInit specific message instance
            if (msgCtrlStatDataInit == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataInit)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataInit)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataMore specific message instance
            if (msgCtrlStatDataMore == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataMore)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataMore)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataStart specific message instance
            if (msgCtrlStatDataStart == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataStart)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataStart)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataTypeInfo specific message instance
            if (msgCtrlStatDataTypeInfo == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataTypeInfo)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataTypeInfo)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataTypeJpeg specific message instance
            if (msgCtrlStatDataTypeJpeg == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataTypeJpeg)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataTypeJpeg)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
        }
        /// <summary>
        /// Version 0x004 deserialization
        /// </summary>
        /// <param name="srReader">File reader</param>
        /// <returns>True if operation is succesful</returns>
        bool Deserialize_v004(System.IO.BinaryReader srReader)
        {
            bool NoError = true;
            try
            {
                int specLoad;

                #region Load destinations
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGDestination tmpDest = new GenMSGDestination();
                    NoError = tmpDest.Deserialize(srReader);
                    MSG_DEST.Add(tmpDest);
                }
                #endregion

                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_AEUC = MSG_DEST[specLoad];
                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_SPECMSG = MSG_DEST[specLoad];
                MSG_START_CHAR = srReader.ReadByte();

                #region Load AEUC message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    AEUC_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load AEUC message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    AEUC_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load SPECMSG message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    SPECMSG_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load SPECMSG message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    SPECMSG_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load the AEUC messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    AEUC_MSG.Add(tmpMsg);
                }
                #endregion

                #region Load the SPECMSG messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    SPECMSG_MSG.Add(tmpMsg);
                }
                #endregion

                SettingDelimitor = srReader.ReadUInt16();

                #region Load msgOMXGetCompInstance specific message instance
                int specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompInstance = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXAllocPortBuffs specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXAllocPortBuffs = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXLinkCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXLinkCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXCompCmds specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXCompCmds = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXCompCmds = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXCompCmds = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompConf specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompConf = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompConf = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompConf = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXSetCompConf specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXSetCompConf = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompConf = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompConf = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompParam specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompParam = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompParam = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompParam = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXSetCompParam specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXSetCompParam = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompParam = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompParam = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSDataMsg specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSDataMsg = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSDataMsg = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSDataMsg = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion

                #region Load msgCtrlStatDataEnd specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataEnd = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataEnd = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataEnd = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataFull specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataFull = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataFull = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataFull = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataInit specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataInit = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataInit = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataInit = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataMore specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataMore = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataMore = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataMore = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataStart specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataStart = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataStart = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataStart = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataTypeInfo specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataTypeInfo = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeInfo = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeInfo = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataTypeJpeg specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataTypeJpeg = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeJpeg = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeJpeg = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return NoError;
        }
        #endregion

        #region Version 0x005 serialization
        /// <summary>
        /// Version 0x004 serialization
        /// </summary>
        /// <param name="srWriter">File writer</param>
        void Serialize_v005(System.IO.BinaryWriter srWriter)
        {
            #region Wtire destination
            srWriter.Write(MSG_DEST.Count);
            for (int i = 0; i < MSG_DEST.Count; i++)
            {
                MSG_DEST[i].Serialize(srWriter);
            }
            #endregion

            #region Write predifined AEUC/SPECMSG message destinations
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_AEUC == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_SPECMSG == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            #endregion

            srWriter.Write(MSG_START_CHAR);

            #region Write AEUC message id
            srWriter.Write(AEUC_MSG_ID.Count);
            for (int i = 0; i < AEUC_MSG_ID.Count; i++)
            {
                AEUC_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write AEUC message status
            srWriter.Write(AEUC_MSG_STAT.Count);
            for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
            {
                AEUC_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message id
            srWriter.Write(SPECMSG_MSG_ID.Count);
            for (int i = 0; i < SPECMSG_MSG_ID.Count; i++)
            {
                SPECMSG_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message status
            srWriter.Write(SPECMSG_MSG_STAT.Count);
            for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
            {
                SPECMSG_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write the AEUC messages
            srWriter.Write(AEUC_MSG.Count);
            for (int i = 0; i < AEUC_MSG.Count; i++)
            {
                ((IAEUCSerialization)AEUC_MSG[i]).Serialize(srWriter);
            }
            #endregion

            #region Write the SPECMSG messages
            srWriter.Write(SPECMSG_MSG.Count);
            for (int i = 0; i < SPECMSG_MSG.Count; i++)
            {
                ((IAEUCSerialization)SPECMSG_MSG[i]).Serialize(srWriter);
            }
            #endregion

            srWriter.Write(SettingDelimitor);

            #region Write msgOMXGetCompInstance specific message instance
            if (msgOMXGetCompInstance == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompPorts specific message instance
            if (msgOMXGetCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXAllocPortBuffs specific message instance
            if (msgOMXAllocPortBuffs == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXLinkCompPorts specific message instance
            if (msgOMXLinkCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXCompCmds specific message instance
            if (msgOMXCompCmds == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXCompCmds)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXCompCmds)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompConf specific message instance
            if (msgOMXGetCompConf == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompConf)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompConf)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXSetCompConf specific message instance
            if (msgOMXSetCompConf == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXSetCompConf)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXSetCompConf)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompParam specific message instance
            if (msgOMXGetCompParam == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompParam)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompParam)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXSetCompParam specific message instance
            if (msgOMXSetCompParam == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXSetCompParam)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXSetCompParam)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSDataMsg specific message instance
            if (msgSYSDataMsg == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSDataMsg)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSDataMsg)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalAlloc specific message instance
            if (msgSYSMarshalAlloc == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalAlloc)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalAlloc)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalFree specific message instance
            if (msgSYSMarshalFree == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalFree)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalFree)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalCopy specific message instance
            if (msgSYSMarshalCopy == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalCopy)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalCopy)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion

            #region Write msgCtrlStatDataEnd specific message instance
            if (msgCtrlStatDataEnd == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataEnd)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataEnd)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataFull specific message instance
            if (msgCtrlStatDataFull == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataFull)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataFull)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataInit specific message instance
            if (msgCtrlStatDataInit == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataInit)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataInit)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataMore specific message instance
            if (msgCtrlStatDataMore == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataMore)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataMore)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataStart specific message instance
            if (msgCtrlStatDataStart == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataStart)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataStart)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataTypeInfo specific message instance
            if (msgCtrlStatDataTypeInfo == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataTypeInfo)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataTypeInfo)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataTypeJpeg specific message instance
            if (msgCtrlStatDataTypeJpeg == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataTypeJpeg)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataTypeJpeg)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
        }
        /// <summary>
        /// Version 0x004 deserialization
        /// </summary>
        /// <param name="srReader">File reader</param>
        /// <returns>True if operation is succesful</returns>
        bool Deserialize_v005(System.IO.BinaryReader srReader)
        {
            bool NoError = true;
            try
            {
                int specLoad;

                #region Load destinations
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGDestination tmpDest = new GenMSGDestination();
                    NoError = tmpDest.Deserialize(srReader);
                    MSG_DEST.Add(tmpDest);
                }
                #endregion

                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_AEUC = MSG_DEST[specLoad];
                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_SPECMSG = MSG_DEST[specLoad];
                MSG_START_CHAR = srReader.ReadByte();

                #region Load AEUC message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    AEUC_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load AEUC message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    AEUC_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load SPECMSG message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    SPECMSG_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load SPECMSG message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    SPECMSG_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load the AEUC messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    AEUC_MSG.Add(tmpMsg);
                }
                #endregion

                #region Load the SPECMSG messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    SPECMSG_MSG.Add(tmpMsg);
                }
                #endregion

                SettingDelimitor = srReader.ReadUInt16();

                #region Load msgOMXGetCompInstance specific message instance
                int specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompInstance = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXAllocPortBuffs specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXAllocPortBuffs = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXLinkCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXLinkCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXCompCmds specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXCompCmds = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXCompCmds = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXCompCmds = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompConf specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompConf = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompConf = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompConf = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXSetCompConf specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXSetCompConf = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompConf = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompConf = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompParam specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompParam = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompParam = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompParam = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXSetCompParam specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXSetCompParam = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompParam = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompParam = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSDataMsg specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSDataMsg = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSDataMsg = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSDataMsg = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalAlloc specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalAlloc = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalAlloc = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalAlloc = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalFree specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalFree = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalFree = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalFree = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalCopy specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalCopy = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalCopy = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalCopy = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion

                #region Load msgCtrlStatDataEnd specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataEnd = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataEnd = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataEnd = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataFull specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataFull = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataFull = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataFull = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataInit specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataInit = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataInit = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataInit = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataMore specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataMore = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataMore = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataMore = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataStart specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataStart = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataStart = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataStart = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataTypeInfo specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataTypeInfo = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeInfo = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeInfo = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataTypeJpeg specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataTypeJpeg = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeJpeg = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeJpeg = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return NoError;
        }
        #endregion

        #region Version 0x006 serialization
        /// <summary>
        /// Version 0x004 serialization
        /// </summary>
        /// <param name="srWriter">File writer</param>
        void Serialize_v006(System.IO.BinaryWriter srWriter)
        {
            #region Wtire destination
            srWriter.Write(MSG_DEST.Count);
            for (int i = 0; i < MSG_DEST.Count; i++)
            {
                MSG_DEST[i].Serialize(srWriter);
            }
            #endregion

            #region Write predifined AEUC/SPECMSG message destinations
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_AEUC == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_SPECMSG == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            #endregion

            srWriter.Write(MSG_START_CHAR);

            #region Write AEUC message id
            srWriter.Write(AEUC_MSG_ID.Count);
            for (int i = 0; i < AEUC_MSG_ID.Count; i++)
            {
                AEUC_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write AEUC message status
            srWriter.Write(AEUC_MSG_STAT.Count);
            for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
            {
                AEUC_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message id
            srWriter.Write(SPECMSG_MSG_ID.Count);
            for (int i = 0; i < SPECMSG_MSG_ID.Count; i++)
            {
                SPECMSG_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message status
            srWriter.Write(SPECMSG_MSG_STAT.Count);
            for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
            {
                SPECMSG_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write the AEUC messages
            srWriter.Write(AEUC_MSG.Count);
            for (int i = 0; i < AEUC_MSG.Count; i++)
            {
                ((IAEUCSerialization)AEUC_MSG[i]).Serialize(srWriter);
            }
            #endregion

            #region Write the SPECMSG messages
            srWriter.Write(SPECMSG_MSG.Count);
            for (int i = 0; i < SPECMSG_MSG.Count; i++)
            {
                ((IAEUCSerialization)SPECMSG_MSG[i]).Serialize(srWriter);
            }
            #endregion

            srWriter.Write(SettingDelimitor);

            #region Write msgOMXGetCompInstance specific message instance
            if (msgOMXGetCompInstance == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompPorts specific message instance
            if (msgOMXGetCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXAllocPortBuffs specific message instance
            if (msgOMXAllocPortBuffs == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXLinkCompPorts specific message instance
            if (msgOMXLinkCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXCompCmds specific message instance
            if (msgOMXCompCmds == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXCompCmds)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXCompCmds)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompConf specific message instance
            if (msgOMXGetCompConf == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompConf)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompConf)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXSetCompConf specific message instance
            if (msgOMXSetCompConf == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXSetCompConf)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXSetCompConf)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompParam specific message instance
            if (msgOMXGetCompParam == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompParam)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompParam)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXSetCompParam specific message instance
            if (msgOMXSetCompParam == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXSetCompParam)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXSetCompParam)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSDataMsg specific message instance
            if (msgSYSDataMsg == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSDataMsg)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSDataMsg)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalAlloc specific message instance
            if (msgSYSMarshalAlloc == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalAlloc)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalAlloc)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalFree specific message instance
            if (msgSYSMarshalFree == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalFree)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalFree)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalCopy specific message instance
            if (msgSYSMarshalCopy == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalCopy)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalCopy)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalDump specific message instance
            if (msgSYSMarshalDump == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalDump)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalDump)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion

            #region Write msgCtrlStatDataEnd specific message instance
            if (msgCtrlStatDataEnd == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataEnd)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataEnd)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataFull specific message instance
            if (msgCtrlStatDataFull == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataFull)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataFull)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataInit specific message instance
            if (msgCtrlStatDataInit == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataInit)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataInit)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataMore specific message instance
            if (msgCtrlStatDataMore == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataMore)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataMore)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataStart specific message instance
            if (msgCtrlStatDataStart == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataStart)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataStart)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataTypeInfo specific message instance
            if (msgCtrlStatDataTypeInfo == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataTypeInfo)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataTypeInfo)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataTypeJpeg specific message instance
            if (msgCtrlStatDataTypeJpeg == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataTypeJpeg)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataTypeJpeg)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
        }
        /// <summary>
        /// Version 0x004 deserialization
        /// </summary>
        /// <param name="srReader">File reader</param>
        /// <returns>True if operation is succesful</returns>
        bool Deserialize_v006(System.IO.BinaryReader srReader)
        {
            bool NoError = true;
            try
            {
                int specLoad;

                #region Load destinations
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGDestination tmpDest = new GenMSGDestination();
                    NoError = tmpDest.Deserialize(srReader);
                    MSG_DEST.Add(tmpDest);
                }
                #endregion

                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_AEUC = MSG_DEST[specLoad];
                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_SPECMSG = MSG_DEST[specLoad];
                MSG_START_CHAR = srReader.ReadByte();

                #region Load AEUC message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    AEUC_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load AEUC message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    AEUC_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load SPECMSG message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    SPECMSG_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load SPECMSG message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    SPECMSG_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load the AEUC messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    AEUC_MSG.Add(tmpMsg);
                }
                #endregion

                #region Load the SPECMSG messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    SPECMSG_MSG.Add(tmpMsg);
                }
                #endregion

                SettingDelimitor = srReader.ReadUInt16();

                #region Load msgOMXGetCompInstance specific message instance
                int specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompInstance = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXAllocPortBuffs specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXAllocPortBuffs = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXLinkCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXLinkCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXCompCmds specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXCompCmds = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXCompCmds = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXCompCmds = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompConf specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompConf = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompConf = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompConf = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXSetCompConf specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXSetCompConf = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompConf = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompConf = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompParam specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompParam = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompParam = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompParam = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXSetCompParam specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXSetCompParam = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompParam = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompParam = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSDataMsg specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSDataMsg = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSDataMsg = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSDataMsg = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalAlloc specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalAlloc = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalAlloc = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalAlloc = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalFree specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalFree = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalFree = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalFree = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalCopy specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalCopy = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalCopy = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalCopy = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalDump specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalDump = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalDump = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalDump = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion

                #region Load msgCtrlStatDataEnd specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataEnd = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataEnd = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataEnd = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataFull specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataFull = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataFull = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataFull = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataInit specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataInit = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataInit = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataInit = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataMore specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataMore = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataMore = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataMore = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataStart specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataStart = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataStart = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataStart = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataTypeInfo specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataTypeInfo = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeInfo = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeInfo = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataTypeJpeg specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataTypeJpeg = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeJpeg = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeJpeg = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return NoError;
        }
        #endregion

        #region Version 0x007 serialization
        /// <summary>
        /// Version 0x004 serialization
        /// </summary>
        /// <param name="srWriter">File writer</param>
        void Serialize_v007(System.IO.BinaryWriter srWriter)
        {
            #region Wtire destination
            srWriter.Write(MSG_DEST.Count);
            for (int i = 0; i < MSG_DEST.Count; i++)
            {
                MSG_DEST[i].Serialize(srWriter);
            }
            #endregion

            #region Write predifined AEUC/SPECMSG message destinations
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_AEUC == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            for (int i = 0; i <= MSG_DEST.Count; i++)
            {
                if (i == MSG_DEST.Count)
                {
                    srWriter.Write(-1);
                }
                else if (MSG_DEST_SPECMSG == MSG_DEST[i])
                {
                    srWriter.Write(i);
                    break;
                }
            }
            #endregion

            srWriter.Write(MSG_START_CHAR);

            #region Write AEUC message id
            srWriter.Write(AEUC_MSG_ID.Count);
            for (int i = 0; i < AEUC_MSG_ID.Count; i++)
            {
                AEUC_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write AEUC message status
            srWriter.Write(AEUC_MSG_STAT.Count);
            for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
            {
                AEUC_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message id
            srWriter.Write(SPECMSG_MSG_ID.Count);
            for (int i = 0; i < SPECMSG_MSG_ID.Count; i++)
            {
                SPECMSG_MSG_ID[i].Serialize(srWriter);
            }
            #endregion

            #region Write SPECMSG message status
            srWriter.Write(SPECMSG_MSG_STAT.Count);
            for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
            {
                SPECMSG_MSG_STAT[i].Serialize(srWriter);
            }
            #endregion

            #region Write the AEUC messages
            srWriter.Write(AEUC_MSG.Count);
            for (int i = 0; i < AEUC_MSG.Count; i++)
            {
                ((IAEUCSerialization)AEUC_MSG[i]).Serialize(srWriter);
            }
            #endregion

            #region Write the SPECMSG messages
            srWriter.Write(SPECMSG_MSG.Count);
            for (int i = 0; i < SPECMSG_MSG.Count; i++)
            {
                ((IAEUCSerialization)SPECMSG_MSG[i]).Serialize(srWriter);
            }
            #endregion

            srWriter.Write(SettingDelimitor);

            #region Write msgOMXGetCompInstance specific message instance
            if (msgOMXGetCompInstance == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompInstance)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompPorts specific message instance
            if (msgOMXGetCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXAllocPortBuffs specific message instance
            if (msgOMXAllocPortBuffs == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXAllocPortBuffs)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXLinkCompPorts specific message instance
            if (msgOMXLinkCompPorts == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXLinkCompPorts)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXCompCmds specific message instance
            if (msgOMXCompCmds == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXCompCmds)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXCompCmds)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompConf specific message instance
            if (msgOMXGetCompConf == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompConf)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompConf)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXSetCompConf specific message instance
            if (msgOMXSetCompConf == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXSetCompConf)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXSetCompConf)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXGetCompParam specific message instance
            if (msgOMXGetCompParam == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXGetCompParam)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXGetCompParam)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgOMXSetCompParam specific message instance
            if (msgOMXSetCompParam == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgOMXSetCompParam)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgOMXSetCompParam)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSDataMsg specific message instance
            if (msgSYSDataMsg == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSDataMsg)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSDataMsg)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalAlloc specific message instance
            if (msgSYSMarshalAlloc == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalAlloc)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalAlloc)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalFree specific message instance
            if (msgSYSMarshalFree == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalFree)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalFree)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalCopy specific message instance
            if (msgSYSMarshalCopy == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalCopy)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalCopy)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalDump specific message instance
            if (msgSYSMarshalDump == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalDump)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalDump)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgSYSMarshalAllocType specific message instance
            if (msgSYSMarshalAllocType == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG.Count; i++)
                {
                    if (AEUC_MSG[i] == msgSYSMarshalAllocType)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG.Count; i++)
                {
                    if (SPECMSG_MSG[i] == msgSYSMarshalAllocType)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion

            #region Write msgCtrlStatDataEnd specific message instance
            if (msgCtrlStatDataEnd == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataEnd)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataEnd)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataFull specific message instance
            if (msgCtrlStatDataFull == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataFull)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataFull)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataInit specific message instance
            if (msgCtrlStatDataInit == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataInit)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataInit)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataMore specific message instance
            if (msgCtrlStatDataMore == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataMore)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataMore)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataStart specific message instance
            if (msgCtrlStatDataStart == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataStart)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataStart)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataTypeInfo specific message instance
            if (msgCtrlStatDataTypeInfo == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataTypeInfo)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataTypeInfo)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
            #region Write msgCtrlStatDataTypeJpeg specific message instance
            if (msgCtrlStatDataTypeJpeg == null)
            {
                //There is no specific message instance set
                srWriter.Write(-1);
            }
            else
            {
                bool notFound = true;
                for (int i = 0; i < AEUC_MSG_STAT.Count; i++)
                {
                    if (AEUC_MSG_STAT[i] == msgCtrlStatDataTypeJpeg)
                    {
                        //The specific message is from the AEUC_MSG array
                        srWriter.Write(0);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                for (int i = 0; i < SPECMSG_MSG_STAT.Count; i++)
                {
                    if (SPECMSG_MSG_STAT[i] == msgCtrlStatDataTypeJpeg)
                    {
                        //The specific message is from the SPECMSG_MSG array
                        srWriter.Write(1);
                        //The array index of the message
                        srWriter.Write(i);
                        notFound = false;
                    }
                }
                if (notFound)
                    throw new Exception("Critical error!\nCannot find message instance!");
            }
            #endregion
        }
        /// <summary>
        /// Version 0x004 deserialization
        /// </summary>
        /// <param name="srReader">File reader</param>
        /// <returns>True if operation is succesful</returns>
        bool Deserialize_v007(System.IO.BinaryReader srReader)
        {
            bool NoError = true;
            try
            {
                int specLoad;

                #region Load destinations
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGDestination tmpDest = new GenMSGDestination();
                    NoError = tmpDest.Deserialize(srReader);
                    MSG_DEST.Add(tmpDest);
                }
                #endregion

                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_AEUC = MSG_DEST[specLoad];
                specLoad = srReader.ReadInt32();
                if (MSG_DEST.Count > 0)
                    MSG_DEST_SPECMSG = MSG_DEST[specLoad];
                MSG_START_CHAR = srReader.ReadByte();

                #region Load AEUC message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    AEUC_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load AEUC message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    AEUC_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load SPECMSG message id
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGId tmpID = new GenMSGId();
                    NoError = tmpID.Deserialize(srReader);
                    SPECMSG_MSG_ID.Add(tmpID);
                }
                #endregion

                #region Load SPECMSG message status
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSGStatus tmpStat = new GenMSGStatus();
                    NoError = tmpStat.Deserialize(srReader);
                    SPECMSG_MSG_STAT.Add(tmpStat);
                }
                #endregion

                #region Load the AEUC messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    AEUC_MSG.Add(tmpMsg);
                }
                #endregion

                #region Load the SPECMSG messages
                specLoad = srReader.ReadInt32();
                for (int i = 0; i < specLoad; i++)
                {
                    GenMSG tmpMsg = new GenMSG(parentTabControl);
                    NoError = ((IAEUCSerialization)tmpMsg).Deserialize(srReader);
                    SPECMSG_MSG.Add(tmpMsg);
                }
                #endregion

                SettingDelimitor = srReader.ReadUInt16();

                #region Load msgOMXGetCompInstance specific message instance
                int specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompInstance = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompInstance = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXAllocPortBuffs specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXAllocPortBuffs = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXAllocPortBuffs = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXLinkCompPorts specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXLinkCompPorts = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXLinkCompPorts = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXCompCmds specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXCompCmds = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXCompCmds = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXCompCmds = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompConf specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompConf = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompConf = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompConf = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXSetCompConf specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXSetCompConf = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompConf = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompConf = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXGetCompParam specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXGetCompParam = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompParam = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXGetCompParam = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgOMXSetCompParam specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgOMXSetCompParam = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompParam = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgOMXSetCompParam = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSDataMsg specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSDataMsg = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSDataMsg = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSDataMsg = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalAlloc specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalAlloc = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalAlloc = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalAlloc = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalFree specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalFree = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalFree = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalFree = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalCopy specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalCopy = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalCopy = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalCopy = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalDump specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalDump = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalDump = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalDump = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgSYSMarshalAllocType specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgSYSMarshalDump = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalAllocType = AEUC_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG.Count > specMsgInstance)
                        {
                            msgSYSMarshalAllocType = SPECMSG_MSG[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion

                #region Load msgCtrlStatDataEnd specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataEnd = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataEnd = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataEnd = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataFull specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataFull = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataFull = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataFull = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataInit specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataInit = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataInit = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataInit = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataMore specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataMore = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataMore = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataMore = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataStart specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataStart = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataStart = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataStart = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataTypeInfo specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataTypeInfo = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeInfo = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeInfo = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
                #region Load msgCtrlStatDataTypeJpeg specific message instance
                specMsgInstance = srReader.ReadInt32();
                if (specMsgInstance == -1)
                {
                    //There is no specific message instance set
                    msgCtrlStatDataTypeJpeg = null;
                }
                else
                {
                    bool notFound = true;
                    //The specific message is from the AEUC_MSG array
                    if (specMsgInstance == 0)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (AEUC_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeJpeg = AEUC_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    //The specific message is from the SPECMSG_MSG array
                    else if (specMsgInstance == 1)
                    {
                        specMsgInstance = srReader.ReadInt32();
                        if (SPECMSG_MSG_STAT.Count > specMsgInstance)
                        {
                            msgCtrlStatDataTypeJpeg = SPECMSG_MSG_STAT[specMsgInstance];
                            notFound = false;
                        }
                    }
                    if (notFound)
                        throw new Exception("Critical error!\nCannot find message instance!");
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return NoError;
        }
        #endregion
        #endregion
    }
}
